package Collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class GenericDemo {
    public static void main(String[] args) {
      Collection<Point> p=new ArrayList<>();
        p.add(new Point(1,2));
        p.add(new Point(3,4));
        p.add(new Point(5,6));
        p.add(new Point(7,8));

        Iterator<Point> it=p.iterator();
        while (it.hasNext()){
            Point pp= it.next();
            System.out.println(pp);
        }
        for (Point pp:p){
            System.out.println(pp);
        }


        /*  Collection<String> c=new ArrayList<>();
        c.add("hello");
        c.add("#");
        c.add("one");
        c.add("#");
        c.add("two");
        c.add("#");
        c.add("three");
        c.add("#");

        Iterator<String> it= c.iterator();
        while (it.hasNext()){
            String str= it.next();
            System.out.println(str);
        }
        for (String str:c){
            System.out.println(str);
        }

       */
    }
}
